//
//  ICMCheckImageCell.m
//  ICrEAM
//
//  Created by rainimute on 16/10/26.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMCheckImageCell.h"

@interface ICMCheckImageCell()

@property (nonatomic, assign) BOOL isAppearance;

@property (nonatomic, assign) NSInteger index;

@property (nonatomic, strong) UIImageView *appearanceImageView;

@property (nonatomic, strong) UIButton *deleteButton;

@end

@implementation ICMCheckImageCell
#pragma mark    设置界面
- (void)setUpCheckImageCellWithImage:(UIImage *)image isAppearance:(BOOL)isAppearance andIndex:(NSInteger)index{
    self.isAppearance = isAppearance;
    self.index = index;
    self.appearanceImageView.image = image;
    self.deleteButton.hidden = NO;
}

- (void)setUpCheckImageCellWithUrl:(NSString *)url isAppearance:(BOOL)isAppearance andIndex:(NSInteger)index{
    self.isAppearance = isAppearance;
    self.index = index;
    NSString *imageName = [NSString stringWithFormat:@"getcar_empty_image_%@",[ICrEAMTool isVW]?@"vw":@"sk"];
    [self.appearanceImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:imageName]];
    self.deleteButton.hidden = NO;
}

- (void)imageViewButtonAction:(UIButton*)sender{
}
-(void)setDeleteButtonHidden{
    self.deleteButton.hidden = YES;
}
- (void)deleteButtonAction:(UIButton*)sender{
    if ([self.delegate respondsToSelector:@selector(checkImageCellDeleteImageButtonAction:andIndex:)]) {
        [self.delegate checkImageCellDeleteImageButtonAction:self.isAppearance andIndex:self.index];
    }
}

- (UIImageView *)appearanceImageView{
    if (!_appearanceImageView) {
        _appearanceImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5, 75, 75)];
        [self.contentView addSubview:_appearanceImageView];
    }
    return _appearanceImageView;
}

- (UIButton *)deleteButton{
    if (!_deleteButton) {
        _deleteButton = [[UIButton alloc]initWithFrame:CGRectMake(55, 0, 30, 30)];
        [_deleteButton setUpButtonWithNormolTitle:nil selectedTitle:nil normolTitleSize:0 selectedTitleSize:0 normolTitleColor:nil selectedTitleColor:nil normolBcakImage:[UIImage imageNamed:@"delete_icon"] selectedBackImage:[UIImage imageNamed:@"delete_icon"] actionSEL:@selector(deleteButtonAction:) target:self];
        [self.contentView addSubview:_deleteButton];
    }
    return _deleteButton;
}



@end


















